package com.aforce3.trailertracer;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

public class Camera
{
	Point3d position;
	Vector3d direction;
	Vector3d up; //TODO: actually use this value
	double fov; //TODO: actually use this number
	
	public Camera()
	{
		this(new Point3d(0,0,0), new Point3d(0,0,-1), new Vector3d(0,1,0), Math.PI/6);
	}
	
	public Camera(Point3d position, Point3d lookat, Vector3d up)
	{
		this(position, lookat, up, Math.PI/6);
	}
	
	public Camera(Point3d position, Point3d lookat, Vector3d up, double fov)
	{
		up.normalize();
		
		this.fov = fov;
		
		this.position = position;
		this.direction = new Vector3d(lookat.x-position.x, lookat.y-position.y, lookat.z-position.z);
		direction.normalize();
		
		Vector3d side = new Vector3d();
		side.cross(direction, up);
		
		this.up = new Vector3d();
		this.up.cross(direction, side);
		this.up.scale(-1);
	}
	
	public Point3d getPosition()
	{
		return position;
	}
	
	public Vector3d getDirection()
	{
		return direction;
	}
	
	public String toString()
	{
		return "(camera position:("+position+") direction:("+direction+") up:("+up+") fov:"+fov+")";
	}

}
